package com.roc.web.action.table;

import java.util.ArrayList;
import java.util.List;

import com.roc.page.BaseSearchCondition;
import com.roc.page.WhereHQLFieldBean;
import com.roc.util.Constance;

public class YSBrealNameRejectSearchCondtion  extends BaseSearchCondition{

	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private String date;
	@Override
	protected List<WhereHQLFieldBean> getWhereHQLFieldBeanList() {
		List<WhereHQLFieldBean> filedBeanList = new ArrayList<WhereHQLFieldBean>();
        
		
		//商户号
		
		return filedBeanList;
	}

	@Override
	protected String getRowCountHQL() {
		StringBuffer  sb = new StringBuffer();
		sb.append(" SELECT COUNT(1) FROM  ");
		sb.append(" ( SELECT t.result_detail,  count(t.result_detail) countCode ,  ratio_to_report(count(t.result_detail)) OVER () pct_total ,  ");
		sb.append(" (SELECT COUNT(1) FROM  apsmgm.t_auditing_item t WHERE  t.audit_code='7001'  AND t.result_code='02'  AND  result_detail IS NOT NULL  ");
		if(Constance.isNotEmpty(date)) {
			sb.append(" AND to_char(t.dt_create, 'yyyymmdd') ="+date.trim());
		}
		sb.append(" ) sumCode    ");
		sb.append("  FROM    apsmgm.t_auditing_item t    ");
		sb.append("  where  t.audit_code='7001'  AND t.result_code='02' AND    result_detail  IS NOT NULL   ");
		 if(Constance.isNotEmpty(date)) {
				sb.append(" AND to_char(t.dt_create, 'yyyymmdd') ="+date.trim());
			}
			sb.append("  GROUP BY t.result_detail  )  ");
		return sb.toString();
	}

	@Override
	protected String getSearchHQL() {
		// TODO Auto-generated method stub
		StringBuffer  sb = new StringBuffer();
		sb.append("  SELECT t.result_detail,  count(t.result_detail) countCode ,  ratio_to_report(count(t.result_detail)) OVER () pct_total ,  ");
		sb.append(" (SELECT COUNT(1) FROM  apsmgm.t_auditing_item t WHERE  t.audit_code='7001'  AND t.result_code='02'  AND  result_detail IS NOT NULL  ");
		if(Constance.isNotEmpty(date)) {
			sb.append(" AND to_char(t.dt_create, 'yyyymmdd') ="+date.trim());
		}
		sb.append(" ) sumCode    ");
		sb.append("  FROM    apsmgm.t_auditing_item t    ");
		sb.append("  where  t.audit_code='7001'  AND t.result_code='02' AND    result_detail  IS NOT NULL   ");
		 if(Constance.isNotEmpty(date)) {
				sb.append(" AND to_char(t.dt_create, 'yyyymmdd') ="+date.trim());
			}
			sb.append("  GROUP BY t.result_detail    ");
		return sb.toString();
	}

	@Override
	protected String getOrderPartOfHQL() {
		// TODO Auto-generated method stub
		return "  ORDER BY t.result_code   ";
	}

	
	
	
	public String getDate() {
		return date;
	}

	public void setDate(String date) {
		this.date = date;
	}

	
	
	
}
